package wei.xinya.pattern.behavioral.strategy;

public class TestStrategy {
    public static void main(String[] args) {

        if (args == null || args.length < 2) {
            System.out.println("参数异常，请输入优惠类型和金额！");
            System.out.println("优惠类型：normal-不优惠；discount-打折；return-满减");
            return;
        }

        String cashType = args[0];
        CashType curCashType = CashType.findByType(cashType);
        System.out.println("优惠类型：" + curCashType.getTypeDesc());

        double value = Double.parseDouble(args[1]);
        System.out.println("金额：" + value);

        // 根据优惠类型，自动执行策略
        DoCash doCash = new DoCash(curCashType);
        System.out.println("优惠后金额：" + doCash.acceptCash(value));
    }
}
